<template>
	<view>
		<view class="top_box">
			<view @click="entireBtn" :class="quanbuAct == 0 ? 'quanbu_btn1' : 'quanbu_btn'">
				全部
			</view>
			<view @click="rareBtn" :class="xiyouAct == 1 ? 'quanbu_btn2' : 'quanbu_btn'">
				<!-- <view class="dot" style="background: #FFDD55;"></view> -->
				稀有
			</view>
			<view @click="epicBtn" :class="shishiAct == 2 ? 'quanbu_btn3' : 'quanbu_btn'">
				<!-- <view class="dot" style="background: #8820FF;"></view> -->
				将军赏
			</view>
			<view @click="extremeBtn" :class="zhizunAct == 3 ? 'quanbu_btn4' : 'quanbu_btn'">
				<!-- <view class="dot" style="background: #F03131;"></view> -->
				大王赏
			</view>

		</view>
		<view style="height:86rpx; width:100%;background-color: #262626;"></view>
		<scroll-view scroll-y='true'
			style="background-image: url('https://mh.qingfentool.vip/upload/image/20230516/05be10811bc664725b37dbeaa51bc456.png');background-size: 100% 100%;  height:calc(100vh - 86rpx);"
			@scrolltolower="quanbuLower" v-if="quanbuAct == 0">

			<view v-for="(item, index) in recordList" :key="index">
				<slot v-if="item.leader_amount > 0" style="color:red;">

					<view class="history_box">
						<view class="left_box">
							<view class="touxiangkuang_box">
								<image style="width: 100%; height:100%;border-radius:50%;" :src="item.frameless_head"
									mode="scaleToFill" />
							</view>
							<view class="image_box">
								<image :src="item.avatar" mode="scaleToFill" />
							</view>
						</view>
						<view class="center_box">
							<view class="midd_box">
								<view class="user_name_box">{{ item.nickname }}</view>
								<view class="shop_name_box"
									style="height: 94rpx;line-height:71rpx;font-size:28rpx;font-weight:700;">霸主结算：{{
										item.leader_amount }}大王币</view>
							</view>
							<view class="beishu_hezi">
							</view>
						</view>
						<view class="right_box">
							<view class="dengji_box">
							</view>
							<view class="shijian_box">{{ item.create_time | formatDate('-') }}</view>
						</view>
					</view>
				</slot>
				<view class="history_box" v-else>
					<view class="left_box">
						<view class="touxiangkuang_box">
							<image style="width: 100%; height:100%;border-radius:50%;" :src="item.frameless_head"
								mode="scaleToFill" />
						</view>
						<view class="image_box">
							<image :src="item.avatar" mode="scaleToFill" />
						</view>
					</view>
					<view class="center_box">
						<view class="midd_box">
							<view class="user_name_box">{{ item.nickname }}</view>
							<view class="shop_name_box">{{ item.prize_name }}</view>
							<view class="bianhao_box">NO.{{ item.times }}</view>
						</view>
						<view class="beishu_hezi">
							<text style="text-align: right;" v-if="boxType == 1">x{{ item.pay_mode }}</text>

						</view>
					</view>
					<view class="right_box">
						<view class="dengji_box">
							<image :src="item.level_icon" mode="scaleToFill" />
						</view>
						<view class="shijian_box">{{ item.create_time | formatDate('-') }}</view>
					</view>
				</view>
			</view>

		</scroll-view>
		<scroll-view scroll-y='true'
			style="background-image: url('https://mh.qingfentool.vip/upload/image/20230516/05be10811bc664725b37dbeaa51bc456.png');background-size: 100% 100%;height:calc(100vh - 86rpx);"
			@scrolltolower="xiyouLower" v-if="xiyouAct == 1">
			<view class="julikaichu">
				距离上一次开出稀有已开出<text style="color: #0057E2; font-size:36rpx;font-weight: 700;">X{{ xiyouKc }}份</text>
			</view>
			<view class="history_box" v-for="(item, index) in uncommonList" :key="index">
				<view class="left_box">
					<view class="touxiangkuang_box">
						<image style="width: 100%; height:100%;border-radius:50%;" :src="item.frameless_head"
							mode="scaleToFill" />
					</view>
					<view class="image_box">
						<image :src="item.avatar" mode="scaleToFill" />
					</view>
				</view>
				<view class="center_box">
					<view class="midd_box">
						<view class="user_name_box">{{ item.nickname }}</view>
						<view class="shop_name_box">{{ item.prize_name }}</view>
						<view class="bianhao_box">NO.{{ item.times }}</view>
					</view>
					<view class="beishu_hezi">
						<text style="text-align: right;" v-if="boxType == 1">x{{ item.pay_mode }}</text>

					</view>
				</view>
				<view class="right_box">
					<view class="dengji_box">

						<image :src="item.level_icon" mode="scaleToFill" />
					</view>
					<view class="shijian_box">{{ item.create_time | formatDate('-') }}</view>
				</view>
			</view>
		</scroll-view>
		<scroll-view scroll-y='true'
			style="background-image: url('https://mh.qingfentool.vip/upload/image/20230516/05be10811bc664725b37dbeaa51bc456.png');background-size: 100% 100%;height:calc(100vh - 86rpx);"
			@scrolltolower="shishiLower" v-if="shishiAct == 2">
			<view class="julikaichu">
				距离上一次开出将军赏已开出<text style="color:#DB0000; font-size:36rpx;font-weight: 700;">X{{ shishiKc }}份</text>
			</view>
			<view class="history_box" v-for="(item, index) in epicList" :key="index">
				<view class="left_box">
					<view class="touxiangkuang_box">
						<image style="width: 100%; height:100%;border-radius:50%;" :src="item.frameless_head"
							mode="scaleToFill" />
					</view>
					<view class="image_box">
						<image :src="item.avatar" mode="scaleToFill" />
					</view>
				</view>
				<view class="center_box">
					<view class="midd_box">
						<view class="user_name_box">{{ item.nickname }}</view>
						<view class="shop_name_box">{{ item.prize_name }}</view>
						<view class="bianhao_box">NO.{{ item.times }}</view>
					</view>
					<view class="beishu_hezi">
						<text style="text-align: right;" v-if="boxType == 1">x{{ item.pay_mode }}</text>

					</view>
				</view>
				<view class="right_box">
					<view class="dengji_box">
						<image :src="item.level_icon" mode="scaleToFill" />
					</view>
					<view class="shijian_box">{{ item.create_time | formatDate('-') }}</view>
				</view>
			</view>
		</scroll-view>
		<scroll-view scroll-y='true'
			style="background-image: url('https://mh.qingfentool.vip/upload/image/20230516/05be10811bc664725b37dbeaa51bc456.png');background-size: 100% 100%;height:calc(100vh - 86rpx);"
			@scrolltolower="zhizunLower" v-if="zhizunAct == 3">
			<view class="julikaichu">
				距离上一次开出大王赏已开出<text style="color: #FCB000 ; font-size:36rpx;font-weight: 700;">X{{ zhizunKc }}份</text>
			</view>
			<view class="history_box" v-for="(item, index) in extremeList" :key="index">
				<view class="left_box">
					<view class="touxiangkuang_box">
						<image style="width: 100%; height:100%;border-radius:50%;" :src="item.frameless_head"
							mode="scaleToFill" />
					</view>
					<view class="image_box">
						<image :src="item.avatar" mode="scaleToFill" />
					</view>
				</view>
				<view class="center_box">
					<view class="midd_box">
						<view class="user_name_box">{{ item.nickname }}</view>
						<view class="shop_name_box">{{ item.prize_name }}</view>
						<view class="bianhao_box">NO.{{ item.times }}</view>
					</view>
					<view class="beishu_hezi">
						<text style="text-align: right;" v-if="boxType == 1">{{ 'x' + item.pay_mode }}</text>

					</view>
				</view>
				<view class="right_box">
					<view class="dengji_box">
						<image :src="item.level_icon" mode="scaleToFill" />
					</view>
					<view class="shijian_box">{{ item.create_time | formatDate('-') }}</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			bianhaoList: [],
			danmuList: [], //弹幕列表
			box_id: null,
			type: null,
			play: '',
			quanbuPage: 1,//全部分页
			xiyouPage: 1,//稀有分页
			shishiPage: 1,//史诗分页
			zhizunPage: 1,//至尊分页
			recordList: [],  //全部列表
			uncommonList: [],//稀有列表
			epicList: [],//史诗列表
			extremeList: [],//至尊列表
			shishiKc: '',//史诗距离开出
			zhizunKc: '',//至尊距离开出
			xiyouKc: '',//稀有距离开出
			quanbuAct: null,
			xiyouAct: null,
			shishiAct: null,
			zhizunAct: null,
			quanbuYeshu: null,//全部页数
			xiyouYeshu: null,//稀有页数
			shishiYeshu: null,//史诗页数
			zhizunYeshu: null,//至尊页数
			boxType: '',//盒子类型
		}
	},
	filters: {
		// 时间戳处理
		formatDate: function (value, spe = '/') {
			value = value * 1000
			let data = new Date(value);
			let year = data.getFullYear();
			let month = data.getMonth() + 1;
			let day = data.getDate();
			let h = data.getHours();
			let mm = data.getMinutes();
			let s = data.getSeconds();
			month = month >= 10 ? month : "0" + month;
			day = day >= 10 ? day : "0" + day;
			h = h >= 10 ? h : "0" + h;
			mm = mm >= 10 ? mm : "0" + mm;
			s = s >= 10 ? s : "0" + s;
			return `${year}${spe}${month}${spe}${day} ${h}:${mm}:${s}`;
		}
	},
	onLoad(options) {
		this.boxType = options.box_type
		this.box_id = options.box_id
		this.type = options.type
		this.play = options.play

	},
	onShow() {
		this.quanbuPage = 1
		this.entireBtn()
	},
	methods: {
		// 全部触底加载
		quanbuLower() {
			if (this.quanbuPage >= this.quanbuYeshu) {
				return false
			}
			this.quanbuPage++
			this.entireBtn(2)
		},
		// 稀有触底加载
		xiyouLower() {
			if (this.xiyouPage >= this.xiyouYeshu) {
				return false
			}
			this.xiyouPage++
			this.rareBtn(2)
		},
		//史诗触底加载
		shishiLower() {
			if (this.shishiPage >= this.shishiYeshu) {
				return false
			}
			this.shishiPage++
			this.epicBtn(2)
		},
		//至尊触底加载
		zhizunLower() {
			if (this.zhizunPage >= this.zhiuznYeshu) {
				return false
			}
			this.zhizunPage++
			this.extremeBtn(2)
		},
		entireBtn(quanbuUp) {//全部上拉
			this.xiyouPage = 1
			this.shishiPage = 1
			this.zhizunPage = 1
			this.quanbuAct = 0
			this.xiyouAct = null
			this.shishiAct = null
			this.zhizunAct = null
			let data = {
				box_id: this.box_id,
				type: 0,
				page: this.quanbuPage

			}
			this.$Request.get(this.$api.index.bulletchat, data).then(res => {
				this.quanbuYeshu = res.data.p.totalPage
				if (quanbuUp == 2) {
					this.recordList = this.recordList.concat(res.data.list)
					// for (let i = 0; i < this.recordList.length; i++) {
					// 	const bianhao = res.data.p.totalCount
					// 	for (let i = 0; i < res.data.p.totalCount; i++) {
					// 		this.$set(this.recordList[i], 'bh', bianhao - i)
					// 	}
					// }
				} else {
					this.recordList = res.data.list
					// for (let i = 0; i < this.recordList.length; i++) {
					// 	const bianhao = res.data.p.totalCount
					// 	for (let i = 0; i < res.data.p.totalCount; i++) {
					// 		this.$set(this.recordList[i], 'bh', bianhao - i)
					// 	}
					// }
				}

			})
		},
		rareBtn(xiyouType) {//稀有
			this.quanbuPage = 1
			this.shishiPage = 1
			this.zhizunPage = 1
			this.quanbuAct = null
			this.xiyouAct = 1
			this.shishiAct = null
			this.zhizunAct = null
			let data = {
				box_id: this.box_id,
				type: 1,
				page: this.xiyouPage
			}
			this.$Request.get(this.$api.index.bulletchat, data).then(res => {
				this.xiyouKc = res.data.lastCount
				this.xiyouYeshu = res.data.p.totalPage
				if (xiyouType == 2) {
					this.uncommonList = this.uncommonList.concat(res.data.list)
				} else {
					this.uncommonList = res.data.list
				}

			})

		},
		epicBtn(shishiType) {//史诗
			this.xiyouPage = 1
			this.quanbuPage = 1
			this.zhizunPage = 1
			this.quanbuAct = null
			this.xiyouAct = null
			this.shishiAct = 2
			this.zhizunAct = null
			let data = {
				box_id: this.box_id,
				type: 2,
				page: this.shishiPage,
			}
			this.$Request.get(this.$api.index.bulletchat, data).then(res => {
				this.shishiYeshu = res.data.p.totalPage
				this.shishiKc = res.data.lastCount
				if (shishiType == 2) {
					this.epicList = this.epicList.concat(res.data.list)
				} else {
					this.epicList = res.data.list
				}

			})

		},
		extremeBtn(zhizunType) {//至尊
			this.xiyouPage = 1
			this.quanbuPage = 1
			this.shishiPage = 1
			this.quanbuAct = null
			this.xiyouAct = null
			this.shishiAct = null
			this.zhizunAct = 3
			let data = {
				box_id: this.box_id,
				type: 3,
				page: this.zhizunPage,

			}
			this.$Request.get(this.$api.index.bulletchat, data).then(res => {
				this.zhizunYeshu = res.data.p.totalPage
				this.zhizunKc = res.data.lastCount
				if (zhizunType == 2) {
					this.extremeList = this.extremeList.concat(res.data.list)
				} else {
					this.extremeList = res.data.list
				}

			})

		},
	}
}
</script>
<style lang="scss"scoped>
.top_box {
	position: fixed;
	top: 0;
	width: 98%;
	height: 80rpx;
	margin: auto;
	display: flex;
	background-color: #262626;
	justify-content: space-between;
	margin-bottom: 86rpx;

	.quanbu_btn {
		width: 24%;
		text-align: center;
		line-height: 80rpx;
		font-size: 34rpx;
		font-weight: 400;
		color: #ffffff;
		display: flex;
		justify-content: center;
		align-items: center;

		// .dot {
		// 	margin-right: 5rpx;
		// 	width: 12rpx;
		// 	height: 12rpx;
		// 	border-radius: 50%;
		// }
	}

	.quanbu_btn1 {
		text-shadow: 0px 4px 20px #FFFFFF;
		width: 24%;
		text-align: center;
		line-height: 80rpx;
		font-size: 34rpx;
		font-weight: 400;
		color: #ffffff;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		font-family: YouSheBiaoTiHei-Bold, YouSheBiaoTiHei;
		// .dot {
		// 	margin-right: 5rpx;
		// 	width: 40rpx;
		// 	height: 20rpx;
		// 	position: absolute;

		// }
	}

	.quanbu_btn2 {
		text-shadow: 0px 4px 20px #0057E2;
		width: 24%;
		text-align: center;
		line-height: 80rpx;
		font-size: 34rpx;
		font-weight: 400;
		color: #ffffff;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		font-family: YouSheBiaoTiHei-Bold, YouSheBiaoTiHei;
		// .dot {
		// 	margin-right: 5rpx;
		// 	width: 40rpx;
		// 	height: 20rpx;
		// 	position: absolute;

		// }
	}

	.quanbu_btn3 {
		text-shadow: 0px 4px 20px #FCB000;
		width: 24%;
		text-align: center;
		line-height: 80rpx;
		font-size: 34rpx;
		font-weight: 400;
		color: #ffffff;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		font-family: YouSheBiaoTiHei-Bold, YouSheBiaoTiHei;
		// .dot {
		// 	margin-right: 5rpx;
		// 	width: 40rpx;
		// 	height: 20rpx;
		// 	position: absolute;

		// }
	}

	.quanbu_btn4 {
		text-shadow: 0px 4px 20px #DB0000;
		width: 24%;
		text-align: center;
		line-height: 80rpx;
		font-size: 34rpx;
		font-weight: 400;
		color: #ffffff;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		font-family: YouSheBiaoTiHei-Bold, YouSheBiaoTiHei;
		// .dot {
		// 	margin-right: 5rpx;
		// 	width: 40rpx;
		// 	height: 20rpx;
		// 	position: absolute;

		// }
	}
}

.julikaichu {
	width: 100%;
	height: 60rpx;
	text-align: center;
	color: #fff;
	line-height: 60rpx;
	font-size: 24rpx;
	font-family: Source Han Sans CN-Medium, Source Han Sans CN;
	font-weight: 500;
}

.history_box {
	width: 100%;
	height: 164rpx;
	border-bottom: 1rpx solid rgba(255, 255, 255, 0.15);
	display: flex;
	justify-content: space-between;

	.left_box {
		width: 15%;
		height: 100%;
		// display: flex;
		// justify-content: center;
		// align-items: center;
		position: relative;

		.touxiangkuang_box {
			width: 116rpx;
			height: 120rpx;
			border-radius: 50%;
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			margin: auto;
			z-index: 9;
		}

		.image_box {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			// background-color: white;
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			margin: auto;

			image {
				width: 100%;
				height: 100%;
				border-radius: 50%;
			}
		}
	}

	.center_box {
		width: 51%;
		height: 100%;
		padding-top: 31rpx;
		display: flex;
		justify-content: space-between;

		.midd_box {
			width: 72%;

			.user_name_box {
				width: 100%;
				height: 38rpx;
				line-height: 38rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 24rpx;
				font-weight: 500;
				color: #FFFFFF;
			}

			.shop_name_box {
				width: 100%;
				height: 30rpx;
				line-height: 30rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 22rpx;
				font-weight: 400;
				color: #FFFFFF;
				margin: 5rpx 0;
			}

			.bianhao_box {
				width: 100%;
				height: 34rpx;
				line-height: 34rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 22rpx;
				font-weight: 700;
				color: #FFFFFF;
			}
		}

		.beishu_hezi {
			width: 25%;
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			font-size: 24rpx;
			font-weight: 500;
			color: #FFFFFF;
			padding-bottom: 30rpx;

		}




	}

	.right_box {
		width: 35%;
		height: 100%;
		padding-top: 50rpx;

		.dengji_box {
			width: 104rpx;
			height: 40rpx;
			margin: auto;
			margin-bottom: 14rpx;
			border-radius: 8rpx;

			image {
				width: 100%;
				height: 100%;
				border-radius: 8rpx;
			}
		}

		.shijian_box {
			width: 100%;
			height: 34rpx;
			text-align: center;
			font-size: 22rpx;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 34rpx
		}
	}
}
</style>